import type { TPageParams, TPageResult } from '@/types/global'
import type { TBannerItem, TCategoryItem, TGuessItem, THotItem } from '@/types/home'
import { http } from '@/utils/http'

class HomeAPI {
  /**
   *
   * @returns 首页-广告区域-小程序
   * @param distributionSite 广告区域展示位置 1首页 2分类商品页
   */
  public static getBannerList(distributionSite = 1) {
    return http<TBannerItem[]>({
      url: '/home/banner',
      method: 'GET',
      data: {
        distributionSite,
      },
    })
  }
  /**
   * @returns 首页-分类类别
   */
  public static getCategoryList() {
    return http<TCategoryItem[]>({
      url: '/home/category/mutli',
      method: 'GET',
    })
  }

  /**
   * @returns 首页-热门推荐
   */
  public static getHotList() {
    return http<THotItem[]>({
      url: '/home/hot/mutli',
      method: 'GET',
      header: {
        'source-client': 'miniapp',
      },
    })
  }

  /**
   * @returns 首页-猜你喜欢
   * @params data{TPageParams} 分页参数
   */
  public static getGuessList(data?: TPageParams) {
    return http<TPageResult<TGuessItem>>({
      url: '/home/goods/guessLike',
      method: 'GET',
      data,
    })
  }
}

export default HomeAPI
